﻿using System;

using Sunyi.Project.WebPoint.DataAccessController;
using Sunyi.Project.WebPoint.DataContract;

namespace Sunyi.Project.WebPoint.BusinessLogic
{
    public partial class RoleServiceManager
    {
        RoleDaoController controller = new RoleDaoController();

        public Role Select(Guid roleId)
        {
            return controller.Select(roleId);
        }

        public void Update(Role role)
        {
            var localRole = controller.Select(role.Id);

            if (localRole == null)
            {
                controller.Insert(role);
            }
            else
            {
                localRole.RoleName = role.RoleName;
                localRole.Description = role.Description;
                localRole.UpdateTimestamp = role.UpdateTimestamp;
                localRole.IsActive = role.IsActive;

                controller.Update(role);
            }
        }
    }
}
